﻿///***************************************************************
/// 시  스  템 : Updms.Fit
/// 단위시스템 : FIT
/// 계      층 : Presentation Layer
/// 프로그램명 : Fit3014p
/// 파  일  명 : Fit3014p.aspx.cs
/// 설      명 : 운동결과 변환기
///***************************************************************
/// 수정ID 일자       이름     내용
///---------------------------------------------------------------
/// CH001  2015-01-27 송시명   최초 작성
///***************************************************************
using System;
using System.Data;
using System.Web.UI;
using System.Web.UI.WebControls;

using SMFramework.Data;

using Base.Dac;
using Base.AppFramework.Web.UI.CommandBar;


namespace Updms.Fit
{
	public partial class Fit3014p : Updms.Common.BaseClass.PageBase
	{
		#region 전역영역

		public static readonly string PID = "Fit3014p";
		public static readonly string gs_path_info = "/updms/Fit/" + PID + ".aspx";

		Global global = new Global();

		#endregion

		#region Page_Load, OnPageLoad

		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				//최초 화면 로딩시 처리해야 할 부분
				OnPageLoad();
				SetDefaultValue();
			}
		}

		//OnPageLoad
		private void OnPageLoad()
		{
			SetLiterals(global.GetLabelInfoByPgmId(PID, LANG_SET));
			SetClientScript();
		}

		#endregion

		#region InitializeComponent

		private void InitializeComponent()
		{
			this.Load += new System.EventHandler(this.Page_Load);
			this.PreRender += new System.EventHandler(this.Page_PreRender);
		}

		#endregion

		#region SetClientScript

		private void SetClientScript()
		{
			//onkeyup 이벤트추가(실제운동기록 - 중량, 반복횟수)
			for (int i = 1; i <= 7; i++)
			{
				TextBox tb_weight = new TextBox();
				TextBox tb_count = new TextBox();

				tb_weight = (TextBox)table_real_training.FindControl("txt_real_action_weight_" + i.ToString());
				tb_count = (TextBox)table_real_training.FindControl("txt_real_action_count_" + i.ToString());

				tb_weight.Attributes.Add("onkeyup", "calcRealTotalWeight(" + i.ToString() + ");");
				tb_count.Attributes.Add("onkeyup", "calcRealTotalWeight(" + i.ToString() + ");");
			}

			//onkeyup 이벤트추가(결과입력용)
			txt_input_set.Attributes.Add("onkeyup", "calcInputTotalWeight();");
			txt_input_action_weight.Attributes.Add("onkeyup", "calcInputTotalWeight();");
			txt_input_action_count.Attributes.Add("onkeyup", "calcInputTotalWeight();");
		}

		#endregion
				
		#region 디테일 Method (SetDefaultValue)

		//SetDefaultValue
		private void SetDefaultValue()
		{
			for (int i = 1; i <= 5; i++)
			{
				TextBox tb_weight = new TextBox();
				TextBox tb_count = new TextBox();

				tb_weight = (TextBox)table_real_training.FindControl("txt_real_action_weight_" + i.ToString());
				tb_count = (TextBox)table_real_training.FindControl("txt_real_action_count_" + i.ToString());

				tb_weight.Text = "12.5";
				tb_count.Text = "15";
			}

			txt_input_set.Text = "5";
			txt_input_action_weight.Text = "12.5";
			txt_input_action_count.Text = "15";

			ClientScript.RegisterStartupScript(typeof(Page), "callAllFunction", "callAllFunction();", true);
		}

		#endregion

		#region Page_PreRender

		//Page_PreRender
		private void Page_PreRender(object sender, System.EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				using (AccessCheck access = new AccessCheck())
				{
					//접근권한 체크
					if (!access.CheckPgmAccessGrant(PID, USER_ID, ACCESS_LOG_INFO))
					{
						Response.Redirect(URL_NO_AUTHORITY_REDIRECT_POPUP);	//사용자의 권한은 요청하신 페이지를 볼 수 없습니다
					}
					//사용권한별 버튼처리
					PagePreRender.SetVisibleCtrl(this, access.CheckPgmUsingGrant(USER_DIV, PID), access.GetVisibleCtrl(PID));
				}
			}
		}

		#endregion

		#region 버튼이벤트

		//새로고침
		protected void ibtn_reload_Click(object sender, EventArgs e)
		{
			SetDefaultValue();
		}

		#endregion

	}
}